package dk.itu.mmad.travelapp5;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class Stations extends ListActivity {

	String[] stations = new String[] {"København H", "Nørreport", "Østerport", "Nordhavn", "Svanemøllen", "Bagsværd", "Kastrup", "Farum", "Gentofte", "Charlottelund"};
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		//setContentView(R.layout.activity_stations);
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, stations);
		setListAdapter(adapter);
	}

	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		String value = stations[(int) id];
		Intent i = new Intent().putExtra("STATION", value);
		setResult(RESULT_OK, i);
		finish();
		Toast.makeText(getApplicationContext(), "Click registered", Toast.LENGTH_SHORT).show();
	}
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.stations, menu);
		return true;
	}

}
